package com.taotao.sso.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.pojo.TaotaoResult;
import com.taotao.sso.service.TokenService;
/**
 * 	根据用户的Token返回的用户的信息
 *  @author  DaiRui  
 *  @ClassName  : TokenController
 *  @Description:
 *  @date  2017年4月16日 下午8:19:28 
 *  @Version  1.0
 */
@Controller
public class TokenController {

	@Autowired
	private TokenService tokenService;
	
	@RequestMapping("/user/token/{token}")
	@ResponseBody
	public Object getUserToken(@PathVariable String token,String callback)
	{
		TaotaoResult result = tokenService.getUserToken(token);
		// 支持jsonp调用
		if (StringUtils.isNotBlank(callback)) {
			MappingJacksonValue jsonValue = new MappingJacksonValue(result);
			jsonValue.setJsonpFunction(callback);
			return jsonValue;
		}
		return result;
	}
}
